import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 导入路由表
import constantRoutes from './router'

const createRouter = () => new Router({
  mode: 'history', 
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  // 重置动态路由
  router.matcher = newRouter.matcher 
}

export default router
